package com.uniubi.uface;

public class QualityJudge {
    private long handle;
    public QualityJudge(int minFaceSize) {
        handle = QualityJudgeJNI.createHandle(minFaceSize);
    }

    public void release() {
        if (handle == 0) {
            return;
        }
        QualityJudgeJNI.releaseHandle(handle);
        handle = 0;
    }

    public JudgeResult judgeImage(String imagePath) {
        JudgeResult judgeResult = new JudgeResult();
        if (handle == 0) {
            return judgeResult;
        }
        return QualityJudgeJNI.judgeImagePath(handle, imagePath);
    }

    public JudgeResult judgeImage(byte[] imageData) {
        JudgeResult judgeResult = new JudgeResult();
        if (handle == 0) {
            return judgeResult;
        }
        return QualityJudgeJNI.judgeImageData(handle, imageData);
    }

    public JudgeResult judgeImage(byte[] pixels, int width, int height) {
        JudgeResult judgeResult = new JudgeResult();
        if (handle == 0) {
            return judgeResult;
        }
        return QualityJudgeJNI.judgeImagePixels(handle, pixels, width, height);
    }

    public void JudgeDir(String dirPath) {
        if (handle == 0) {
            return;
        }
        QualityJudgeJNI.judgeDir(handle, dirPath);
    }
}
